/*=============================================================================
#    The element-comm is a tentative program used to test our ideas.           
#                       Copyright (C)  bgao                                    
#
#     This program is free software; you can redistribute it and/or            
#      modify it under the terms of the GNU General Public License             
#     as published by the Free Software Foundation; either version 2           
#         of the License, or (at your option) any later version.               
#
#     This program is distributed in the hope that it will be useful,          
#    but WITHOUT ANY WARRANTY; without even the implied warranty of           
#     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the            
#             GNU General Public License for more details.                    
#
#    You should have received a copy of the GNU General Public License        
#     along with this program; if not, write to the Free Software             
#      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,             
#                       MA  02110-1301, USA.                                  
#==============================================================================
# $Id: mac_start.c 348 2010-11-29 09:01:16Z bgao $ 
#
# $Author: bgao $ 
#
# $Revision: 348 $ 
#
# $Date: 2010-11-29 17:01:16 +0800 (星期一, 29 十一月 2010) $ 
#
# Description: 
#
=============================================================================*/
/*! @file mac_start.c
 *  @brief This file implements the MAC start request primitive,
 *         which is used by the coordinator to set up the network.
 */
#include <stdio.h>
#include "mac.h"

/*! MAC start request primitive.
 *  @param req pointer to the mac_start_req_t structure.
 *  @return return the results of this operation.
 */
int8 mac_start_req(mac_start_req_t *req)
{
    mac_set_pan_id(req->pan_id);
    mac_set_beacon_order(req->bcn_order);
    mac_set_superframe_order(req->superframe_order);
    mac_set_associated_pan_coord(true);
    mac_set_short_addr(0x0000);

    rf_set_pan_id(req->pan_id);
    rf_set_short_addr(0x0000);
    rf_set_pan_coord();
    rf_enable_addr_recg();

    MAC_DEBUG("mac_start_req: successfully form the network.\n");
    return MAC_OK;
}
